﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace AAA.Forms.Components.Util
{
    public class TextBoxUtil
    {
        struct LVITEM
        {
            private Int32 mask;
            private Int32 iItem;
            private Int32 iSubItem;
            private Int32 state;
            private Int32 stateMask;
            private string pszText;
            private Int32 cchTextMax;
            private Int32 iImage;
            private Int32 lParam;
            private Int32 iIndent;
        }

        [DllImport("user32.dll", EntryPoint = "SendMessageA")]
        static extern Int32 SendMessage(Int32 hwnd, Int32 wMsg, Int32 wParam, LVITEM pitem);

        private const string EM_GETRECT = "&HB2";
        private const string EM_SETRECTNP = "&HB4";

        private struct RECT
        {
            public long Left;
            public long Top;
            public long Right;
            public long Bottom;
        }

        private void SetVCenterText(TextBox userdefineTextBox)
        {
            //RECT rc;
            //long UserControlTop;
            //long UserControlBottom;
            //if (userdefineTextBox.Multiline == false)
            //{
            //    SendMessage(userdefineTextBox.hwnd, EM_GETRECT, 0, rc);
            //    UserControlTop = ((rc.Bottom - rc.Top) - (UserControl.Parent.TextHeight("H") / Screen.TwipsPerPixelY)) / 2;
            //    UserControlBottom = ((rc.Bottom - rc.Top) + (UserControl.Parent.TextHeight("H") / Screen.TwipsPerPixelY)) / 2;
            //    rc.Top = UserControlTop;
            //    rc.Bottom = UserControlBottom;

            //    userdefineTextBox.Alignment = vbCenter;

            //    SendMessage(userdefineTextBox.hwnd, EM_SETRECTNP, 0, rc);

            //    userdefineTextBox.Refresh();
            //}
        }
    }
}
